import { request } from './request.js'

export function CreateOrder(params) {
  return request({ method: 'Post', url: `/user/order/create`, data: params });
}

export function FindUserOrders(params) {
  const array = [];
  params.orderStatus && array.push(`orderStatus=${params.orderStatus}`);
  params.lastOrderId && array.push(`lastId=${params.lastOrderId}`);
  params.searchDirection && array.push(`searchDirection=${params.searchDirection}`);
  return request({ method: 'Get', url: `/user/order/find?${array.join('&')}` });
}

export function GetUserOrderById(params) {
  return request({ method: 'Get', url: `/user/order/${params.orderId}` });
}

export function SearchMerchantOrders(params) {
  const array = [];
  params.lastOrderId && array.push(`lastId=${params.lastOrderId}`);
  params.searchDirection && array.push(`searchDirection=${params.searchDirection}`);
  return request({ method: 'Get', url: `/merchant/order/search?${array.join('&')}` });
}

export function FindMerchantOrders(params) {
  const array = [];
  params.lastId && array.push(`lastId=${params.lastId}`);
  params.searchDirection && array.push(`searchDirection=${params.searchDirection}`);
  return request({ method: 'Get', url: `/merchant/order/find?${array.join('&')}` });
}

export function GetMerchantOrderById(params) {
  return request({ method: 'Get', url: `/merchant/order/${params.orderId}` });
}

export function MerchantAcceptOrder(params) {
  return request({ method: 'Post', url: `/merchant/order/accept/${params.orderId}` });
}